package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EvConfig;
import com.ruoyi.system.service.IEvConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统设置Controller
 * 
 * @author Camelminger
 * @date 2025-11-10
 */
@RestController
@RequestMapping("/system/configOfCam")
public class EvConfigController extends BaseController
{
    @Autowired
    private IEvConfigService evConfigService;

    /**
     * 查询系统设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:configOfCam:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvConfig evConfig)
    {
        startPage();
        List<EvConfig> list = evConfigService.selectEvConfigList(evConfig);
        return getDataTable(list);
    }

    /**
     * 导出系统设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:configOfCam:export')")
    @Log(title = "系统设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EvConfig evConfig)
    {
        List<EvConfig> list = evConfigService.selectEvConfigList(evConfig);
        ExcelUtil<EvConfig> util = new ExcelUtil<EvConfig>(EvConfig.class);
        util.exportExcel(response, list, "系统设置数据");
    }

    /**
     * 获取系统设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:configOfCam:query')")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Long configId)
    {
        return success(evConfigService.selectEvConfigByConfigId(configId));
    }

    /**
     * 新增系统设置
     */
    @PreAuthorize("@ss.hasPermi('system:configOfCam:add')")
    @Log(title = "系统设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvConfig evConfig)
    {
        return toAjax(evConfigService.insertEvConfig(evConfig));
    }

    /**
     * 修改系统设置
     */
    @PreAuthorize("@ss.hasPermi('system:configOfCam:edit')")
    @Log(title = "系统设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvConfig evConfig)
    {
        return toAjax(evConfigService.updateEvConfig(evConfig));
    }

    /**
     * 删除系统设置
     */
    @PreAuthorize("@ss.hasPermi('system:configOfCam:remove')")
    @Log(title = "系统设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Long[] configIds)
    {
        return toAjax(evConfigService.deleteEvConfigByConfigIds(configIds));
    }
}
